#!/bin/sh

SVNBase="/root/backup/svn"
MySqlBase="/root/backup/mysql"
BugsDataBase="/root/backup/bugs/data"

service mysqld stop
service httpd stop

for svn in `ls $SVNBase`
do
    echo "recovery svn repos:$svn..."
    rsync -a --delete $SVNBase/$svn/ /var/www/svn/$svn/  &>/dev/null
    chown -R apache.apache /var/www/svn/$svn/
    chcon -R -t httpd_sys_content_t /var/www/svn/$svn
done

for mysql in `ls $MySqlBase`
do
    echo -e "recovery mysql db:$mysql..."
    rsync -a --delete $MySqlBase/$mysql/ /var/lib/mysql/$mysql/  &>/dev/null
done

echo "recovery bugs data dir..."
rsync -a --delete $BugsDataBase/ /var/www/html/bugs/data/ &>/dev/null

cp -f /root/backup/svn-access-control /etc/
cp -f /root/backup/svn-auth-users /etc/

echo "recall all services up..."

service mysqld start
service httpd start

echo -e "All Done!"
